From: Florian Müllner Date: Thu, 10 Apr 2025 18:09:35 +0000 (+0200) Subject: status/doNotDisturb: Add new quick toggle X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~124^2^2~9 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=68e0feddb3809558eb578f25e688cc7167608bb6;p=gnome-shell.git status/doNotDisturb: Add new quick toggle It is a simple on/off control, which makes it a good fit for quick settings. It also makes sense to expose the feature together with other system controls, and while this somewhat removes the control from the context of notifications, that doesn't seem to be an issue on other platforms. Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/8339 Part-of: --- diff --git a/js/js-resources.gresource.xml b/js/js-resources.gresource.xml index df23e5eb7..c116810a7 100644 --- a/js/js-resources.gresource.xml +++ b/js/js-resources.gresource.xml @@ -146,6 +146,7 @@ ui/status/brightness.js ui/status/camera.js ui/status/darkMode.js + ui/status/doNotDisturb.js ui/status/dwellClick.js ui/status/keyboard.js ui/status/location.js diff --git a/js/ui/panel.js b/js/ui/panel.js index b8d05634c..d89b12c6b 100644 --- a/js/ui/panel.js +++ b/js/ui/panel.js @@ -29,6 +29,7 @@ import * as SystemStatus from './status/system.js'; import * as LocationStatus from './status/location.js'; import * as NightLightStatus from './status/nightLight.js'; import * as DarkModeStatus from './status/darkMode.js'; +import * as DoNotDisturb from './status/doNotDisturb.js'; import * as BacklightStatus from './status/backlight.js'; import * as ThunderboltStatus from './status/thunderbolt.js'; import * as AutoRotateStatus from './status/autoRotate.js'; @@ -543,6 +544,7 @@ class QuickSettings extends PanelMenu.Button { this._thunderbolt = new ThunderboltStatus.Indicator(); this._nightLight = new NightLightStatus.Indicator(); this._darkMode = new DarkModeStatus.Indicator(); + this._doNotDisturb = new DoNotDisturb.Indicator(); this._backlight = new BacklightStatus.Indicator(); this._powerProfiles = new PowerProfileStatus.Indicator(); this._rfkill = new RFKillStatus.Indicator(); @@ -564,6 +566,7 @@ class QuickSettings extends PanelMenu.Button { if (this._network) this._indicators.add_child(this._network); this._indicators.add_child(this._darkMode); + this._indicators.add_child(this._doNotDisturb); this._indicators.add_child(this._backlight); this._indicators.add_child(this._powerProfiles); if (this._bluetooth) @@ -596,6 +599,7 @@ class QuickSettings extends PanelMenu.Button { this._addItemsBefore(this._powerProfiles.quickSettingsItems, sibling); this._addItemsBefore(this._nightLight.quickSettingsItems, sibling); this._addItemsBefore(this._darkMode.quickSettingsItems, sibling); + this._addItemsBefore(this._doNotDisturb.quickSettingsItems, sibling); this._addItemsBefore(this._backlight.quickSettingsItems, sibling); this._addItemsBefore(this._rfkill.quickSettingsItems, sibling); this._addItemsBefore(this._autoRotate.quickSettingsItems, sibling); diff --git a/js/ui/status/doNotDisturb.js b/js/ui/status/doNotDisturb.js new file mode 100644 index 000000000..fe313d2e8 --- /dev/null +++ b/js/ui/status/doNotDisturb.js @@ -0,0 +1,39 @@ +import Gio from 'gi://Gio'; +import GObject from 'gi://GObject'; + +import {QuickToggle, SystemIndicator} from '../quickSettings.js'; + +const DoNotDisturbToggle = GObject.registerClass( +class DoNotDisturbToggle extends QuickToggle { + constructor() { + super({ + title: _('Do Not Disturb'), + iconName: 'notifications-disabled-symbolic', + toggleMode: true, + }); + + this._settings = new Gio.Settings({ + schema_id: 'org.gnome.desktop.notifications', + }); + this._settings.bind('show-banners', + this, 'checked', + Gio.SettingsBindFlags.INVERT_BOOLEAN); + } +}); + +export const Indicator = GObject.registerClass( +class Indicator extends SystemIndicator { + constructor() { + super(); + this._indicator = this._addIndicator(); + this._indicator.icon_name = 'notifications-disabled-symbolic'; + + const toggle = new DoNotDisturbToggle(); + toggle.bind_property('checked', + this._indicator, 'visible', + GObject.BindingFlags.SYNC_CREATE); + + this.quickSettingsItems.push(toggle); + } +}); + diff --git a/po/POTFILES.in b/po/POTFILES.in index 9acd2f1d2..1798b876f 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -68,6 +68,7 @@ js/ui/status/backlight.js js/ui/status/bluetooth.js js/ui/status/brightness.js js/ui/status/darkMode.js +js/ui/status/doNotDisturb.js js/ui/status/dwellClick.js js/ui/status/keyboard.js js/ui/status/location.js